<%-- 
    Document   : addProblem
    Created on : 3/04/2011, 10:15:12 PM
    Author     : Jhon
--%>

<%@page import="control.Controller"%>
<%@page import="vo.VOProblem"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%  String pname =  request.getParameter("pname");
    String pcode =  request.getParameter("pcode");
    String ccode =  request.getParameter("ccode");
    String time=  request.getParameter("time");
    String diff= request.getParameter("diff");
    String textarea= request.getParameter("textarea");
    if(pname ==null || pname=="" || time==null || time =="" || textarea==null || textarea==""){
    response.sendRedirect("../Problemas/BuscarProblema.jsp");
    return;
    }
    Controller con = Controller.getInstance();
    VOProblem p = new VOProblem();
    p.setAccepted(0);
    p.setContestCode(ccode);
    p.setDescription(textarea);
    p.setDifficulty(Integer.parseInt(diff));
    p.setName(pname);
    p.setProblemCode(pcode);
    p.setSubmissions(0);
    p.setTime(Integer.parseInt(time));
    p.setVisible(true);

    try{
    boolean bien = con.createProblem(p);
    }catch(Exception e){
        session.setAttribute("ERROR", e.getMessage());
        response.sendRedirect("../Error/Error.jsp");
        return;
    }
    response.sendRedirect("../Problemas/BuscarProblema.jsp");
    %>